﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FDelete_GetList]
	(
	@CompanyId INT,
	@table_type VARCHAR(50)	,
	@sDate VARCHAR(10)
	)
AS
BEGIN
	DECLARE @str_Where VARCHAR(1000)
	
	IF @table_type='Finance_RunningAccount'--收入
      BEGIN
      	SELECT id,fr.Summary, fr.Income AS [Money], fr.EName AS UserName, (select companyname from company WHERE company.Id= fr.CompanyId) AS companyname, fr.Renling,
      	       fr.CreateDate
      	  FROM Finance_RunningAccount fr WHERE fr.CompanyId=@CompanyId and CONVERT(VARCHAR(10),CreateDate,120) =@sDate AND Renling=1
      END
	ELSE IF @table_type='Finance_Outlay'--支出
	  BEGIN
	  	SELECT id,fo.CreateDate, fo.Summary, fo.OutlayPrice AS [Money], fo.EName AS UserName,
	  	        (select companyname from company WHERE company.Id= fo.CompanyIdCur) AS companyname, fo.OutlayReason
	  	  FROM Finance_Outlay fo WHERE fo.CompanyIdCur=@CompanyId AND fo.CateOneId<>19 AND CONVERT(VARCHAR(10),CreateDate,120) =@sDate
	  END   
	  ELSE IF  @table_type='L_Reimbursement'--报销
	    BEGIN
	    	SELECT id,lr.CompanyId, lr.Summary, lr.CompanyName, lr.[Money],
	    	       lr.username,lr.lrrq AS CreateDate
	    	  FROM L_Reimbursement lr WHERE CompanyId=@CompanyId AND  CONVERT(VARCHAR(10),lrrq,120) =@sDate
	    END      
	    ELSE IF @table_type='L_Dealings'--公司往来
	     BEGIN
	     	SELECT id,ld.O_CompanyName AS CompanyName, ld.je AS [Money], ld.CreateDate, ld.UserName,ld.I_CompanyName+'借款' as summary
	     	  FROM L_Dealings ld WHERE ld.O_CompanyId=@CompanyId AND CONVERT(VARCHAR(10),CreateDate,120) =@sDate
	     END  
	     ELSE 
	     	BEGIN
	     		RETURN
	     	END                   
END
